package com.code.petapp.activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;

import com.code.petapp.R;
import com.code.petapp.bean.OrderBean;
import com.code.petapp.databinding.ActivitySettingBinding;
import com.code.petapp.http.HttpListener;
import com.code.petapp.util.OrderUtils;
import com.code.petapp.util.SPCommonUtils;

public class SettingActivity extends BaseActivity {
    ActivitySettingBinding binding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding=ActivitySettingBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        binding.manager.setOnClickListener(view -> startActivity(new Intent(SettingActivity.this, PersonActivity.class)));
        binding.modPwd.setOnClickListener(view -> startActivity(new Intent(SettingActivity.this, ModPwdActivity.class)));
        binding.logout.setOnClickListener(view -> {
            AlertDialog.Builder builder = new AlertDialog.Builder(SettingActivity.this);
            builder.setIcon(R.drawable.icon);
            builder.setTitle("退出登录？");
            builder.setMessage("您确定退出登录吗？");
            builder.setPositiveButton("确定",
                            (DialogInterface dialog, int arg1) -> {
                                dialog.dismiss();
                                SPCommonUtils.getInstance().Clear();
                                Intent intent = new Intent(this, StartActivity.class);
                                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                                startActivity(intent);
                                finish();
                            })
                    .setNegativeButton("取消",
                            (DialogInterface dialog, int arg1) -> {
                                dialog.dismiss();
                            });
            builder.create().show();
        });
    }
}